#include <avr/io.h>
#include <avr/pgmspace.h>

#include "dkbasic.h"
#include "dkstring.h"



// Unshifted characters
unsigned char unshifted[][2] = {
{0x01,DKKEY_F9},			// F9
{0x03,DKKEY_F5},			// F5
{0x04,DKKEY_F3},			// F3
{0x05,DKKEY_F1},			// F1
{0x06,DKKEY_F2},			// F2
{0x07,DKKEY_F12},			// F12
{0x09,DKKEY_F10},			// F10
{0x0A,DKKEY_F8},			// F8
{0x0B,DKKEY_F6},			// F6
{0x0C,DKKEY_F4},			// F4
{0x0D,9},
{0x0E,'`'},
//{0x11,DKKEY_ALT},			// MODIFIER left alt (91 = right alt)
{0x15,'q'},
{0x16,'1'},
{0x1A,'z'},
{0x1B,'s'},
{0x1C,'a'},
{0x1D,'w'},
{0x1E,'2'},
{0x21,'c'},
{0x22,'x'},
{0x23,'d'},
{0x24,'e'},
{0x25,'4'},
{0x26,'3'},
{0x29,' '},
{0x2A,'v'},
{0x2B,'f'},
{0x2C,'t'},
{0x2D,'r'},
{0x2E,'5'},
{0x31,'n'},
{0x32,'b'},
{0x33,'h'},
{0x34,'g'},
{0x35,'y'},
{0x36,'6'},
{0x3A,'m'},
{0x3B,'j'},
{0x3C,'u'},
{0x3D,'7'},
{0x3E,'8'},
{0x41,','},
{0x42,'k'},
{0x43,'i'},
{0x44,'o'},
{0x45,'0'},
{0x46,'9'},
{0x49,'.'},
{0x4A,'/'},
{0x4B,'l'},
{0x4C,';'},
{0x4D,'p'},
{0x4E,'-'},
{0x52,'\''},
{0x54,'['},
{0x5B,']'},
{0x5D,'\\'},
{0x55,'='},
{0x5A,13}, 
{0x66,8},				// backspace
{0x69,DKKEY_NUM_1},
{0x6B,DKKEY_NUM_4},
{0x6C,DKKEY_NUM_7},
{0x70,DKKEY_NUM_0},
{0x71,DKKEY_NUM_PER},			// keypad ./delete
{0x72,DKKEY_NUM_2},
{0x73,DKKEY_NUM_5},
{0x74,DKKEY_NUM_6},
{0x75,DKKEY_NUM_8},
{0x76,0x1B},			// escape
//{0x77,DKKEY_NUMLOCK},	// 9477 = pause  92FC = print screen
{0x78,DKKEY_F11},			// F11
{0x79,'+'},			// keypad +
{0x7A,DKKEY_NUM_3},
{0x7B,'-'},			// keypad -
{0x7C,'*'},			// keypad *
{0x7D,DKKEY_NUM_9},
{0x7E,DKKEY_SCROLL},	// scroll lock  FE = ctrl-break    FC = ctrl-sysrq
{0x83,DKKEY_F7},			// F7

// keys listed past this point are actually E0+sc - now sc.7 is set

//{0x91,DKKEY_ALT},			// 91 = right alt
//{0x94,''},			// right ctrl
//{0x9F,''},			// 9F left 'Win' key (LGUI)
//{0xA1,'c'},			// A1 = voldown (sony vaio)
//{0xA3,'d'},			// A3 = mute (sony vaio)
//{0xA7,''},			// A7 right 'Win' key (RGUI)
{0xAA,DKKEY_BATOK},	// AA = response from keyboard reset BAT
{0xAF,DKKEY_APPS},	// AF 'properties' key (APPS)
//{0xB2,'b'},			// B2 = volup (sony vaio)
//{0xBF,''},			// BF = sleep (sony vaio)
{0xCA,'/'},			// CA = numpad /
{0xDA,13},			// DA = numpad enter
{0xE9,DKKEY_END},		//e9 = end
{0xEB,DKKEY_LEFT},			//eb = left	
{0xEC,DKKEY_HOME},			//ec = home
{0xF0,DKKEY_INS},			//f0 = ins
{0xF1,DKKEY_DEL},			//f1 = del
{0xF2,DKKEY_DOWN},			//f2 = down
{0xF4,DKKEY_RIGHT},			//f4 = right
{0xF5,DKKEY_UP},			//f5 = up
{0xF7,DKKEY_PAUSE},
{0xF8,DKKEY_PRTSCR},
{0xFA,DKKEY_PGDN},			//fa = pgdn
{0xFC,DKKEY_SYSRQ},			// FC = ctrl-sysrq    92FC = print screen
{0xFD,DKKEY_PGUP},			//fd = pgup
{0xFE,DKKEY_BREAK},			// FE = ctrl-break    

{0,0}
};
// shift-numlock = 0xFA

// if high bit of scancode set, check for entry in table >= 0x80 - if not found, return entry with high bit clear (compatibility mode)


// Shifted characters
unsigned char shifted[][2] = {
{0x0E,'~'},
{0x15,'Q'},
{0x16,'!'},
{0x1A,'Z'},
{0x1B,'S'},
{0x1C,'A'},
{0x1D,'W'},
{0x1E,'@'},
{0x21,'C'},
{0x22,'X'},
{0x23,'D'},
{0x24,'E'},
{0x25,'$'},
{0x26,'#'},
{0x2A,'V'},
{0x2B,'F'},
{0x2C,'T'},
{0x2D,'R'},
{0x2E,'%'},
{0x31,'N'},
{0x32,'B'},
{0x33,'H'},
{0x34,'G'},
{0x35,'Y'},
{0x36,'^'},
{0x39,'L'},
{0x3A,'M'},
{0x3B,'J'},
{0x3C,'U'},
{0x3D,'&'},
{0x3E,'*'},
{0x41,'<'},
{0x42,'K'},
{0x43,'I'},
{0x44,'O'},
{0x45,')'},
{0x46,'('},
{0x49,'>'},
{0x4A,'?'},
{0x4B,'L'},
{0x4C,':'},
{0x4D,'P'},
{0x4E,'_'},
{0x52,'\"'},
{0x54,'{'},
{0x55,'+'},
{0x5B,'}'},
{0x5D,'|'},
{0,0}
};

